$(document).ready(function() {
	queryTableListData();
});

/**
 * 查询列表
 * 
 * @returns
 */
function queryTableListData() {
	$.ajax({
		type : 'post',
		url : pt.base + "pt/ureportfenlei/listdata.do",
		dataType : "json",
		data : {},
		success : function(result) {
			$('#dataListTable').bootstrapTable("load", result.data || []);
		}
	});
}
function dataOperation(id, row, index) {
	var str = "";
	if (row.state == 2) {
		str = str
				+ "<a class='btn btn-sm btn-info clickBefore' href='javascript:void(0)' onclick=changeState('"
				+ row.id
				+ "','1')  title='发布' style='padding: 1px 5px; width: 50px;'>发布</a>";
		str = str
				+ "<a class='btn btn-sm btn-info clickBefore' href='javascript:void(0)' onclick=editorReport('"
				+ row.name
				+ "')  title='设计' style='padding: 1px 5px; width: 50px;'>设计</a>";
		str = str
				+ "<a class='btn btn-sm btn-danger btnDanger' href='javascript:void(0)' onclick=delectReport('"
				+ row.id
				+ "')  title='删除' style='padding: 1px 5px; width: 50px;'>删除</a>";
	}
	if (row.state == 1) {
		str = str
				+ "<a class='btn btn-sm btn-danger btnDanger' href='javascript:void(0)' onclick=changeState('"
				+ row.id
				+ "','2') title='停用' style='padding: 1px 5px; width: 50px;'>停用</a>";
	}
	return str;
}
function jobstate(value, row, index) {
	if (value == '1') {
		return '发布';
	}
	if (value == '2') {
		return '未发布';
	}
}
function formatName(value,row,index){
	return value.substring(value.indexOf(":") + 1,value.indexOf("."));
}
/**
 * 发布报表
 * 
 * @param id
 * @param state
 * @returns
 */
function changeState(id, state) {
	$.ajax({
		type : 'post',
		url : pt.base + "pt/ureportfenlei/changeStatus.do",
		dataType : "json",
		data : {
			reportid : id,
			state : state
		},
		success : function(result) {
			queryTableListData();
			pt.alertInfo(result.msg)
		}
	});
}
/**
 * 编辑报表
 * 
 * @returns
 */
function editorReport(name) {
	newMenuItem2(pt.base + "ureport/designer?_u="+name,"","设计报表");
}
/**
 * 添加报表
 * 
 * @returns
 */
function andUreport() {
	newMenuItem2(pt.base + "ureport/designer","","设计报表");
}


/**
 * 删除报表
 */
function delectReport(id){
	$.ajax({
		type : 'post',
		url : pt.base + "pt/ureportfenlei/delectReport.do",
		dataType : "json",
		data : {
			reportid : id
		},
		success : function(result) {
			queryTableListData();
			pt.showMsg("操作成功")
		}
	});
}






















